<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
<html>
	<head>
		<base href="<%=basePath%>">
		<title>小说信息修改页</title>
		<link href="css/bootstrap.css" rel='stylesheet' type='text/css'/>
		<link href="jquery/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css" type="text/css" rel="stylesheet"/>
		<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
		<script src="js/popper.min.js"></script>
		<script src="bootstrap-4.2.1/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="jquery/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js"></script>
		<script type="text/javascript" src="jquery/bootstrap-datetimepicker-master/locale/bootstrap-datetimepicker.zh-CN.js"></script>
		<script>

			$(function (){

                $("#updateBtn").click(function () {

                    $.ajax({
                        url: "novel/updateNovel.do",
                        data: {
                            "id":$("#id").val(),
                            "name": $("#name").val(),
                            "novelColumn": $("#novelColumn").val(),
                            "review": $("#review").val(),
                            "states": $("#states").val(),
                        },
                        type: "get",
                        dataType: "json",
                        success: function (data) {

                            if (data) {
                                alert("更新成功!");
                                window.location.href = "jsp/setting/novelManage.jsp";
                            } else {
                                alert("更新失败!")
                            }

                        }
                    })

                })

			})

		</script>
	</head>
	<body>

		<form class="form-horizontal" role="form">
			<input type="hidden" id="id" value="${n.id}">
			<div class="form-group">
				<label for="name" class="col-sm-2 control-label">小说名<span style="font-size: 15px; color: red;">*</span></label>
				<div class="col-sm-10" style="width: 300px;">
					<input type="text" class="form-control" id="name"  placeholder="${n.name}">
				</div>
			</div>
			<div class="form-group">
				<label for="novelColumn" class="col-sm-2 control-label">小说所属栏目</label>
				<div class="col-sm-10" style="width: 300px;">
					<select class="form-control" id="novelColumn" placeholder="${n.novelColumn}">
						<option></option>
						<c:forEach items="${novelColumnList}" var="n">
							<option value="${n.value}">${n.text}</option>
						</c:forEach>
					</select>
				</div>
				<label for="review" class="col-sm-2 control-label">书评</label>
				<div class="col-sm-10" style="width: 300px;">
					<input type="text" class="form-control" id="review"  placeholder="${n.review}">
				</div>
			</div>
			<div class="form-group">
				<label for="states" class="col-sm-2 control-label">小说状态</label>
				<div class="col-sm-10" style="width: 300px;">
					<select class="form-control" id="states" placeholder="${n.states}">
						<option></option>
						<c:forEach items="${statesList}" var="s">
							<option value="${s.value}">${s.text}</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div>
				<button type="button" class="btn btn-default">取消</button>
				<button type="button" class="btn btn-primary" id="updateBtn">更新</button>
			</div>
		</form>
	</body>
</html>
